<script>
    var a = 10;
    function test() {
        console.log(a) // undedined
        a = 100
        console.log(a) // 100 
        console.log(this.a) // 10
        var a
        console.log(a) // 100
    }
    test()
</script>

<script>
    const person={name:'jd'}
    //使用 Object.defineProperty() 添加的属性值是不可修改（immutable）的
    Object.defineProperty(person,'age',{value:21})
    // Object.defineProperty(person,'age',{value:21,enumerable:true,writable:true})
    person.age=18
    console.log(person)//18
    console.log(Object.keys(person))//['name','age']

</script>

<script>
    console.log('=============')
    console.log(1)
    setTimeout(()=>{
        console.log(2)
        Promise.resolve().then(()=>{
            console.log(3)
        })
    },0)
    new Promise(function(resolve,reject){
        console.log(4)
        setTimeout(function(){
            console.log(5)
            resolve(6)
        },0)
    }).then(res=>{
        console.log(7)
        setTimeout(()=>{
            console.log(res)
        },0)
    })
    // 1 4 2 3 5 7 6
</script>